package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

import DataObjects.Fire;
import DataObjects.RecipeAdditions;

public class GetFiredRecipes {
	
	
	Vector<Fire> fires ;
	
	public GetFiredRecipes()
	{
		this.fires=new Vector<Fire>();
	}
	
	
	public Vector<Fire> getFiredRecipes()
	{
		SQLConnection sc=new SQLConnection();
		
		
		try {
			
		PreparedStatement ps = sc.getConnection().prepareStatement("SELECT F.orderId,F.rid,F.rname,F.timeFire,F.mid,F.extraName,F.extraRid,F.souceName,F.souceRid,F.comments,F.actionLevel,E.name,E.eid,ETT.tid,F.quantity FROM fire F, employee_table_timeslot ETT, employee E WHERE F.isFired='1' AND F.isSubmitted='0' AND F.orderId=ETT.orderId AND ETT.eid=E.eid ;");	

		ResultSet rs=ps.executeQuery();	

		while(rs.next())
		{
			Fire fire=new Fire();
			fire.setOrderId(Integer.toString(rs.getInt(1)));
			fire.setRecipeId(Integer.toString(rs.getInt(2)));
			fire.setRecipeName(rs.getString(3));
			fire.setTimeOfFire(rs.getString(4));
			fire.setMid(Integer.toString(rs.getInt(5)));
			RecipeAdditions extra =new RecipeAdditions();
			extra.setName(rs.getString(6));
			extra.setId(Integer.toString(rs.getInt(7)));
			fire.setExtra(extra);
			RecipeAdditions souce =new RecipeAdditions();
			souce.setName(rs.getString(8));
			souce.setId(Integer.toString(rs.getInt(9)));
			fire.setSouce(souce);
			fire.setComments(rs.getString(10));
			fire.setActionLevel(rs.getString(11));
			fire.setWaiterName(rs.getString(12));
			fire.setWaiterId(Integer.toString(rs.getInt(13)));
			fire.setTableNo(Integer.toString(rs.getInt(14)));
			fire.setQuantity(Integer.toString(rs.getInt(15)));
			fires.add(fire);
			
			
		}

		
		
		 ps.close();
		 rs.close();
		 sc.getConnection().close();
		
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		
		
		return fires;
	}

}
